﻿<UserControl x:Class="StockholmsStad.Windows.UI.Modules.Maintenance.Controls.FilingListView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:commoncontrols="clr-namespace:StockholmsStad.Windows.UI.Infrastructure.Controls;assembly=StockholmsStad.Windows.UI.Infrastructure">
    <UserControl.Resources>
        <!--Define the template for the first column to contain a CheckBox control-->
        <DataTemplate x:Key="SelectionCell">
            <StackPanel Orientation="Horizontal">
                <CheckBox IsChecked="{Binding Path=IsSelected, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListViewItem}}}"/>
            </StackPanel>
        </DataTemplate>

    </UserControl.Resources>

    <GroupBox Header="Arkivering" Margin="0,10,5,5" Padding="5,10,5,5" HorizontalAlignment="Left" VerticalAlignment="Top">

        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>

            <StackPanel Orientation="Vertical" Grid.Row="0">
                <StackPanel Orientation="Horizontal">
                    <Label x:Name="lblFrom" Content="Datum Från:" />
                    <commoncontrols:DateTimePicker x:Name="dtpDateFrom" Grid.Row="1" Grid.Column="0" Margin="0,0,5,0" />
                    <Label x:Name="lblTo" Content="Till:" />
                    <commoncontrols:DateTimePicker x:Name="dtpDateTo" Grid.Row="1" Grid.Column="2" Margin="0,0,5,0" />
                    <Button x:Name="btnSearch" Content="Sök" Width="70" Height="22" Margin="10,0,0,0" Click="btnSearch_Click" />
                    <TextBlock x:Name="NoOfCouples" Text="" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,0,10,0" />
                </StackPanel>
            </StackPanel>

            <ListView x:Name="lvCouples" SelectionMode="Multiple" VerticalAlignment="Top" Grid.Row="1" MaxHeight="400"
                      ItemsSource="{Binding}" ItemContainerStyle="{DynamicResource ListItemContainerStyle}"
                      CheckBox.Unchecked="OnUncheckItem"
                      ScrollViewer.HorizontalScrollBarVisibility="Auto"
                      ScrollViewer.VerticalScrollBarVisibility="Auto" SourceUpdated="lvCouples_SourceUpdated">
                <ListView.View>
                    <GridView>
                        <GridViewColumn CellTemplate="{StaticResource SelectionCell}" Width="50">
                            <GridViewColumn.Header>
                                <CheckBox x:Name="cbSelectAll" Style="{DynamicResource CheckBoxHeaderStyle}" Content="Välj" 
                                          Click="OnSelectAllChanged" Padding="5,0,0,0" HorizontalAlignment="Left" Margin="0,0,0,0" />
                            </GridViewColumn.Header>
                        </GridViewColumn>

                        <GridViewColumn Header="Person 1" DisplayMemberBinding="{Binding Person1.FullName}" />
                        <GridViewColumn Header="Person 2" DisplayMemberBinding="{Binding Person2.FullName}" />
                        <GridViewColumn Header="Kontaktperson" DisplayMemberBinding="{Binding ContactPerson.FullName}" />
                        <GridViewColumn Header="Adress" DisplayMemberBinding="{Binding Person1.Address.StreetAddress}" />
                        <GridViewColumn Header="Mail" DisplayMemberBinding="{Binding Email}" />
                        <GridViewColumn Header="Telefon" DisplayMemberBinding="{Binding Person1.PhoneNumber}" />
                        <GridViewColumn Header="Mobil" DisplayMemberBinding="{Binding Person1.CellPhoneNumber}" />
                    </GridView>
                </ListView.View>
            </ListView>

            <StackPanel Orientation="Horizontal" Grid.Row="2" FlowDirection="RightToLeft" Margin="10">
                <Button x:Name="btnDepersonate" Content="Arkivera" Margin="0, 0, 0, 0" Click="btnDepersonate_Click" />
            </StackPanel>

        </Grid>

    </GroupBox>


</UserControl>
